/*
	jGrouse framework
	Copyright 2007 by Denis Riabtchik 
	All rights reserved.
	
	Licensed under modified BSD license. See license.txt for details
*/


/**
	@module jgrouse.widgets.InputText
	@requires jgrouse.widgets.Widget
*/

jgrouse.module(
{
	name : 'jgrouse.widgets.InputText',
	requires : ['jgrouse.widgets.InputControl'],
	imports : ['jgrouse.widgets.InputControl'],
	body : function(embed)
	{
		eval(embed);
		
		jgrouse.widgets.registerWidget('inputText', 'jgrouse.widgets.InputText');
		
		/**
			Widget implementing input text field (equivalent to HTML's &lt;input type="text"&gt;).
			The widget is registered under alias "inputText".
			Exported properties:
			<ul>
				<li>value</li>
			</ul>
			@class jgrouse.widgets.InputText
			@extends jgrouse.widgets.InputControl
		*/
		jgrouse.define('jgrouse.widgets.InputText', 'jgrouse.widgets.InputControl', function(salt)
		{
			eval(salt);
			
			return {
				/**
					@constructor initialize
					@inheritdesc
				*/
				initialize : function(options, styles)
				{
					_super(this, 'initialize', options, styles);
					this.setAttribute('type', 'text');
					this.enableEvent('change');
				},
				
				/**
					Event handler for onChange event. Fires the change for <b>value</b> property
					@function onChange
					@param {DOMEvent} event
				*/
				onChange : function(event)
				{
					var val = this._domElement.value;
					var oldVal = this.getValue();
					this.setValue(val);
					this.firePropertyChange('value', val, oldVal);
				}
			}
		});
	}
});